/**
 * 
 */
package pt.mleiria.sAction.utils;

import java.sql.Date;

import javax.servlet.jsp.PageContext;

import org.apache.commons.lang.time.FastDateFormat;
import org.displaytag.decorator.DisplaytagColumnDecorator;
import org.displaytag.exception.DecoratorException;
import org.displaytag.properties.MediaTypeEnum;

/**
 * @author Manuel
 * 
 */
public class DateDecorator implements DisplaytagColumnDecorator {

	private FastDateFormat dateFormat;

	public DateDecorator() {
		dateFormat = FastDateFormat.getInstance("dd-MM-yyyy");
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see org.displaytag.decorator.DisplaytagColumnDecorator#decorate(java.lang.Object,
	 *      javax.servlet.jsp.PageContext,
	 *      org.displaytag.properties.MediaTypeEnum)
	 */
	public Object decorate(Object columnValue, PageContext pageContext,
			MediaTypeEnum media) throws DecoratorException {
		if(columnValue != null){
			Date date = (Date) columnValue;
			return dateFormat.format(date);
		}else{
			return null;
		}
	}

	/*
	 * public String getDataRecProv1(){
	 * 
	 * Date teste = (Date)getCurrentRowObject();
	 * 
	 * return "-"; }
	 */

}
